package com.dwcode.macro.service.impl;

import com.dwcode.macro.dao.EmpDao;
import com.dwcode.macro.entity.Emp;
import com.dwcode.macro.dto.Pagination;
import com.dwcode.macro.service.EmpService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpDao empDao;

    @Override
    public Pagination<Emp> getEmps(Pagination page) {
        int start = (page.getPageNum() - 1) * page.getPageSize();
        int total = this.empDao.getCount();
        List<Emp> rows = this.empDao.getEmps(start, page.getPageSize());
        page.setTotal(total);
        page.setRows(rows);
        return page;
    }
}
